package com.lhstack.opensearch.query;

import java.util.function.Consumer;

/**
 * @Description TODO
 * @Copyright: Copyright (c) 2022 ALL RIGHTS RESERVED.
 * @Author lhstack
 * @Date 2022/6/20 11:21
 * @Modify by
 */
public class PageRequest<T> {

    private final int page;

    private final int size;

    private final Consumer<T> consumer;

    /**
     *
     * @param page
     * @param size
     * @param consumer 查询条件
     * @return
     * @param <T>
     */
    public static <T> PageRequest<T> ofRequest(int page, int size, Consumer<T> consumer) {
        return new PageRequest<>(page, size, consumer);
    }

    public static <T> PageRequest<T> ofRequest(int page, int size) {
        return new PageRequest<T>(page, size);
    }

    public PageRequest(int page, int size) {
        this.page = page;
        this.size = size;
        this.consumer = searchSourceBuilder -> {
        };
    }

    public PageRequest(int page, int size, Consumer<T> consumer) {
        this.page = page;
        this.size = size;
        this.consumer = consumer;
    }

    public Consumer<T> getConsumer() {
        return consumer;
    }

    public int getPage() {
        return page;
    }

    public int getSize() {
        return size;
    }
}
